export default defineBackground(() => {
  console.log('Hello background!', { id: browser.runtime.id });
  browser.runtime.onInstalled.addListener(() => {
    // 添加右键菜单
    browser.contextMenus.create({
      id: 'mock',
      title: 'Mock数据',
      contexts: ['page']
    });

    // 监听右键菜单点击事件
    browser.contextMenus.onClicked.addListener((info: any, tab: any) => {
      if (info.menuItemId === 'mock') {
        console.log('onClicked1', info, tab);
        tab.id && browser.tabs.sendMessage(tab.id, { from: 'Service Worker', message: 'mock' });
        browser.sidePanel.open({windowId: tab.windowId})
      }
    });
  });
});
